package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"log"
	"net/http"
)

func main() {

	// 1.创建路由
	r := gin.Default()
	// 2.绑定路由规则，执行的函数
	// gin.Context，封装了request和response
	r.GET("/", func(c *gin.Context) {
		log.Println("【默认项目】服务启动成功 监听端口 8000")
		c.String(http.StatusOK, "hello World!")
	})

	r.GET("/ping", func(c *gin.Context) {
		c.JSON(http.StatusOK, gin.H{
			"message": "pong",
		})
	})

	//r.GET("/someGet", getting)
	//r.POST("/somePost", posting)
	//r.PUT("/somePut", putting)
	//r.DELETE("/someDelete", deleting)
	//r.PATCH("/somePatch", patching)
	//r.HEAD("/someHead", head)
	//r.OPTIONS("/someOptions", options)

	// 3.监听端口，默认在8080
	// Run("里面不指定端口号默认为8080")
	r.Run(":8000")

}

func Print() {
	i, j := 1, 1
	for j <= 9 {
		for i <= j {
			fmt.Printf("%v*%v=%v ", i, j, i*j)
			i++
		}
		fmt.Printf("\n")
		j++
		i = 1
	}
}
